package pri.hillchen.std.concurren.chapter7;

import pri.hillchen.std.concurren.chapter7.util.CancellableTask;

import java.util.Random;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.RunnableFuture;

/**
 * @author:hillchen
 * @DESCRIPTION:
 * @Date: Created in 11:20 2018/2/9 0009.
 */
public class BlockingInterruptedDemo2 {

    public static void main(String[] args) throws InterruptedException {
        final Random random = new Random();
        final BlockingQueue<Integer> blockingQueue = new ArrayBlockingQueue<Integer>(15);
        final CountDownLatch starLatch = new CountDownLatch(1);
        CancellableTask<Boolean> prouctorRunner = new CancellableTask() {
            @Override
            public void cancell() {

            }

            @Override
            public RunnableFuture newTask() {
                return null;
            }

            @Override
            public Object call() throws InterruptedException {
                starLatch.await();
                while (true) {
                    blockingQueue.put(random.nextInt());
                    Thread.sleep(10);
                }
            }

        };

    }
}
